package com.yuyou.fn.electronicinvoice.service.impl;

import com.github.wens.framework.service.impl.SuperServiceImpl;
import com.github.wens.mybatisplus.examples.Example;
import com.yuyou.fn.electronicinvoice.entity.FinanceSubjectCampus;
import com.yuyou.fn.electronicinvoice.mapper.FinanceSubjectCampusMapper;
import com.yuyou.fn.electronicinvoice.service.IFinanceSubjectCampusService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 *
 * FinanceSubjectCampus 表数据服务层接口实现类
 *
 */
@Service
public class FinanceSubjectCampusServiceImpl extends SuperServiceImpl<FinanceSubjectCampusMapper, FinanceSubjectCampus,Long> implements IFinanceSubjectCampusService {

    @Override
    public void deleteByFinanceSubjectId(Long financeSubjectId) {
        Example<FinanceSubjectCampus> example= FinanceSubjectCampus.createExample();
        Example.Criteria criteria=example.createCriteria();
        criteria.andEqualTo("financeSubjectId",financeSubjectId);
        this.deleteByExample(example);
    }

    @Override
    public List<FinanceSubjectCampus> findByCampusIds(List<Long> campusIds,Integer subjectStatus) {
        if (campusIds==null ||campusIds.size()<=0){
            return Collections.EMPTY_LIST;
        }
        Example<FinanceSubjectCampus> example= FinanceSubjectCampus.createExample();
        Example.Criteria criteria=example.createCriteria();
        criteria.andIn("campusId",campusIds);
        criteria.andEqualTo("subjectStatus",subjectStatus);
        return this.findListByExample(example);
    }

    @Override
    public void changeBySubjectIdAndSubjectStatus(Long financeSubjectId, Integer subjectStatus) {
        Example<FinanceSubjectCampus> example= FinanceSubjectCampus.createExample();
        Example.Criteria criteria=example.createCriteria();
        criteria.andEqualTo("financeSubjectId",financeSubjectId);
        FinanceSubjectCampus financeSubjectCampus=new FinanceSubjectCampus();
        financeSubjectCampus.setSubjectStatus(subjectStatus);
        this.updateSelectiveByExample(financeSubjectCampus,example);
    }
}